﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Runtime.Serialization;
using System.Collections.ObjectModel;
using System.Linq;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Diagnostics;
using System.ComponentModel;
using System.IO.IsolatedStorage;
using System.IO;
using System.Threading;
using System.Collections;
using Microsoft.Phone.Shell;
using BankProject.Models;
using BankProject.Strings;
using System.Device.Location;
using BankProject.Entities;
using System.Windows.Threading;
using BankProject.ViewModels;
using TweetSharp;

namespace BankProject.ViewModels
{
    [DataContractAttribute]
    public class MainViewModel : BaseViewModel
    {
        private GeoCoordinate location;
        [DataMemberAttribute]
        public GeoCoordinate Location
        {
            get
            {
                return location;
            }
            set
            {
                location = value;
                NotifyPropertyChanged("Location");
            }
        }

        public double Course
        {
            get
            {
                return Location.Course;
            }
            set
            {
                double course = value;
                while (course > 360)
                {
                    course -= 360;
                }
                while (course < 0)
                {
                    course += 360;
                }

                Location.Course = course;
                NotifyPropertyChanged("Location");
            }
        }

        [DataMemberAttribute]
        public LocationManager LocationManager { get; set; }

        private Review review;
        [DataMemberAttribute]
        public Review Review
        {
            get
            {
                return review;
            }
            set
            {
                review = value;
                NotifyPropertyChanged("Review");
            }
        }

        public MainViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                LocationManager = new LocationManager(true);
            }
            else
            {
                Location = new GeoCoordinate(50, 30);
            }

            Review = new Review();
        }

        public void UnTombstoned()
        {
            LocationManager.UnTombstoned();
        }

        public void UnDormant()
        {
            LocationManager.UnDormant();
        }

        public void Deactivated()
        {
            LocationManager.Deactivated();
        }

        public TwitterService CLient
        {
            get; set;
            
        }

        public bool userAuthenticated
        {
            get;
            set;
        }
    }
}
